import java.lang.reflect.Array;
import java.util.Arrays;

public class MyStack {
    private int[] elem;
    private int useSize;
    public  static final int DEFAULT_CAPACITY =10;
    public MyStack( ) {
       this.elem=new int[DEFAULT_CAPACITY];
    }
    public boolean isFull(){
        if(useSize==elem.length){
            return true;
        }else{
            return false;
        }
    }
    public void push(int val){
        if(isFull()){
            this.elem= Arrays.copyOf(elem,elem.length*2);
        }
        elem[useSize]=val;
        this.useSize++;
    }
    public int pop(){
        if(!isEmpty()){
            int oldVal=elem[useSize];
            useSize--;
            return oldVal;
        }else{
            throw new nullException("Stock为空");

        }
    }
    public int peek(){
        if(!isEmpty()){
            return this.elem[useSize];
        }else{
            throw new nullException("Stock为空");
        }

    }
    public  boolean isEmpty(){
        return useSize==0;
    }
}
